clear
set mem 500m

/*
File:	cepr_basic_read_all.do
Date:	Nov 21, 2006
	Feb 10, 2009
	Feb 22, 2011
	Jan 6, 2012
	Jan 3, 2013
	Jan 10, 2013 - Add December data
	Dec 20, 2013 - Months 1-11 for 2013
	Mar 12, 2015, CEPR ORG Version 2.0
	Apr  1, 2015, CEPR ORG Version 2.0.1
	March 1, 2016, CEPR ORG Version 2.1
	Oct 12, 2016, CEPR ORG Version 2.1.1
	Feb 9, 2017, CEPR ORG Version 2.2
	Apr 21, 2017, CEPR ORG Version 2.2.1
	Apr 10, 2018, CEPR ORG Version 2.3
	Mar 22, 2019, CEPR ORG Version 2.4
	Jul 24, 2019, CEPR ORG Version 2.4.1
	Feb 05, 2020, CEPR ORG Version 2.5
		
Desc:	Retrieves raw CPS Basic data and adds data labels
*/

      
/* 1994 */
capture program drop b1994
program define b1994
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-March 1994 */
      if 1<=`i' & `i'<=3 { /* Jan-March 1994 */
	    cd "$locbas"
	    cd 1994
	    unzipfile `month'94pub.zip
	    /* uses Jan 1994 coding */
	    !$copy `month'94pub.cps "$locbas/1994/cpsb_01_1994.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_01_1994.do /* uses Jan 1994 coding */
	    gen int year=1994
	    compress
	    cd "$locbas"
	    cd 1994
	    saveold cps_basic_raw_1994_`i'.dta, replace
	    !$erase cpsb_01_1994.txt
		!$erase `month'94pub.cps
	    } /* Jan-March 1994 */
      /* April-Dec 1994 */
      if 4<=`i' & `i'<=12 { /* April-Dec 1994 */
	    cd "$locbas"
	    cd 1994
	    unzipfile `month'94pub.zip
	    /* use April 1994 coding */
	    !$copy `month'94pub.cps "$locbas/1994/cpsb_04_1994.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_04_1994.do /* uses April 1994 coding */
	    gen int year=1994
	    compress
	    cd "$locbas"
	    cd 1994
	    saveold cps_basic_raw_1994_`i'.dta, replace
	    !$erase cpsb_04_1994.txt
		!$erase `month'94pub.cps
	    } /* April-Dec 1994 */
local i=`i'+1
} /* loop through months */
end

/* 1995 */
capture program drop b1995
program define b1995
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-May 1995 */
      if 1<=`i' & `i'<=5 { /* Jan-May 1995 */
	    cd "$locbas"
	    cd 1995
	    unzipfile `month'95pub.zip
	    /* use April 1994 coding */
	    !$copy `month'95pub.cps "$locbas/1994/cpsb_04_1994.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_04_1994.do /* uses April 1994 coding */
	    gen int year=1995
	    compress
	    cd "$locbas"
	    cd 1995
	    saveold cps_basic_raw_1995_`i'.dta, replace
	    !$erase `month'95pub.cps
		
	    cd "$locbas"
	    cd 1994
	    !$erase cpsb_04_1994.txt
	    } /* Jan-May 1995 */
      /* June-Aug 1995 */
      if 6<=`i' & `i'<=8 { /* June-Aug 1995 */
	    cd "$locbas"
	    cd 1995
	    unzipfile `month'95pub.zip
	    /* use June 1995 coding */
	    !$copy `month'95pub.cps "$locbas/1995/cpsb_06_1995.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_06_1995.do /* uses June 1995 coding */
	    gen int year=1995
	    compress
	    cd "$locbas"
	    cd 1995
	    saveold cps_basic_raw_1995_`i'.dta, replace
	    
	    !$erase cpsb_06_1995.txt
		!$erase `month'95pub.cps
	    } /* June-Aug 1995 */
      /* Sep-Dec 1995 */
      if 9<=`i' & `i'<=12 { /* Sep-Dec 1995 */
	    cd "$locbas"
	    cd 1995
	    unzipfile `month'95pub.zip
	    /* use Sep 1995 coding */
	    !$copy `month'95pub.cps "$locbas/1995/cpsb_09_1995.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_09_1995.do /* uses Sep 1995 coding */
	    gen int year=1995
	    compress
	    cd "$locbas"
	    cd 1995
	    saveold cps_basic_raw_1995_`i'.dta, replace
	    
	    !$erase cpsb_09_1995.txt
		!$erase `month'95pub.cps
	    } /* Sep-Dec 1995 */
local i=`i'+1
} /* loop through months */
end


/* 1996 */
capture program drop b1996
program define b1996
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-Dec 1996 */
      if 1<=`i' & `i'<=12 { /* Jan-Dec 1996 */
	    cd "$locbas"
	    cd 1996
		unzipfile `month'96pub.zip
	    /* use Sep 1995 coding */
	    !$copy `month'96pub.cps "$locbas/1995/cpsb_09_1995.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_09_1995.do /* uses Sep 1995 coding */
	    gen int year=1996
	    compress
	    cd "$locbas"
	    cd 1996
	    saveold cps_basic_raw_1996_`i'.dta, replace
	    !$erase `month'96pub.cps
		
	    cd "$locbas"
	    cd 1995
	    !$erase cpsb_09_1995.txt
	    } /* Jan-Dec 1996 */
local i=`i'+1
} /* loop through months */
end

/* 1997 */
capture program drop b1997
program define b1997
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec  {
      /* Jan-Dec 1997 */
      if 1<=`i' & `i'<=12 { /* Jan-Dec 1997 */
	    cd "$locbas"
	    cd 1997
	    unzipfile `month'97pub.zip
	    /* use Sep 1995 coding */
	    !$copy `month'97pub.cps "$locbas/1995/cpsb_09_1995.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_09_1995.do /* uses Sep 1995 coding */
	    gen int year=1997
	    compress
	    cd "$locbas"
	    cd 1997
	    saveold cps_basic_raw_1997_`i'.dta, replace
	    !$erase `month'97pub.cps
		
	    cd "$locbas"
	    cd 1995
	    !$erase cpsb_09_1995.txt
	    } /* Jan-Dec 1997 */
local i=`i'+1
} /* loop through months */
end

/* 1998 */
capture program drop b1998
program define b1998
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-Dec 1998 */
      if 1<=`i' & `i'<=12 { /* Jan-Dec 1998 */
	    cd "$locbas"
	    cd 1998
	    unzipfile `month'98pub.zip
	    /* use Jan 1998 coding */
	    !$copy `month'98pub.cps "$locbas/1998/cpsb1998.txt"
	    
	    cd "$locbdo"
	    do cps_basic_read_1998.do /* uses Jan 1998 coding */
	    gen int year=1998
	    compress
	    cd "$locbas"
	    cd 1998
	    saveold cps_basic_raw_1998_`i'.dta, replace
	    
		!$erase `month'98pub.cps
	    !$erase cpsb1998.txt
	    } /* Jan-Dec 1998 */
local i=`i'+1
} /* loop through months */
end


/* 1999 */
capture program drop b1999
program define b1999
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-Dec 1999 */
      if 1<=`i' & `i'<=12 { /* Jan-Dec 1999 */
	    cd "$locbas"
	    cd 1999
	    unzipfile `month'99pub.zip
	    /* use Jan 1998 coding */
		if `i'!=10 & `i'!=12 {
			!$copy `month'99pub.dat "$locbas/1998/cpsb1998.txt"
		}
		else{
			!$copy `month'99pub.cps "$locbas/1998/cpsb1998.txt"
		}
	    	    
	    cd "$locbdo"
	    do cps_basic_read_1998.do /* uses Jan 1998 coding */
	    gen int year=1999
	    compress
	    cd "$locbas"
	    cd 1999
	    saveold cps_basic_raw_1999_`i'.dta, replace
	    if `i'!=10 & `i'!=12 {
			!!$erase `month'99pub.dat
		}
		else{
			!$erase `month'99pub.cps 
		}
				
	    cd "$locbas"
	    cd 1998
	    !$erase cpsb1998.txt
	    } /* Jan-Dec 1999 */
local i=`i'+1
} /* loop through months */
end

/* 2000 */
capture program drop b2000
program define b2000
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-Dec 2000 */
      if 1<=`i' & `i'<=12 { /* Jan-Dec 2000 */
	    cd "$locbas"
	    cd 2000
	    unzipfile `month'00pub.zip
	    /* use Jan 1998 coding */
		if `i'!=2 & `i'!=6 & `i'!=8 & `i'!=9 & `i'!=10 & `i'!=11 & `i'!=12 {
		    !$copy `month'00pub.dat "$locbas/1998/cpsb1998.txt"
		}
		else{
			!$copy `month'00pub.cps "$locbas/1998/cpsb1998.txt"
		}
		
	    
	    cd "$locbdo"
	    do cps_basic_read_1998.do /* uses Jan 1998 coding */
	    gen int year=2000
	    compress
	    cd "$locbas"
	    cd 2000
	    saveold cps_basic_raw_2000_`i'.dta, replace
	    if `i'!=2 & `i'!=6 & `i'!=8 & `i'!=9 & `i'!=10 & `i'!=11 & `i'!=12 {
		    !$erase `month'00pub.dat 
		}
		else{
			!$erase `month'00pub.cps 
		}
		
	    cd "$locbas"
	    cd 1998
	    !$erase cpsb1998.txt
	    } /* Jan-Dec 2000 */
local i=`i'+1
} /* loop through months */
end

/* 2001 */
capture program drop b2001
program define b2001
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-Dec 2001 */
      if 1<=`i' & `i'<=12 { /* Jan-Dec 2001 */
	    cd "$locbas"
	    cd 2001
	    unzipfile `month'01pub.zip
	    /* use Jan 1998 coding */
	    if `i'==3 {
		    !$copy `month'01pub.dat "$locbas/1998/cpsb1998.txt"
		}
		else{
			!$copy `month'01pub.cps "$locbas/1998/cpsb1998.txt"
		}
		
	    cd "$locbdo"
	    do cps_basic_read_1998.do /* uses Jan 1998 coding */
	    gen int year=2001
	    compress
	    cd "$locbas"
	    cd 2001
	    saveold cps_basic_raw_2001_`i'.dta, replace
	    if `i'==3 {
		    !$erase `month'01pub.dat 
		}
		else{
			!$erase `month'01pub.cps 
		}
		
	    cd "$locbas"
	    cd 1998
	    !$erase cpsb1998.txt
	    } /* Jan-Dec 2001 */
local i=`i'+1
} /* loop through months */
end

/* 2002 */
capture program drop b2002
program define b2002
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      /* Jan-Dec 2002 */
      if 1<=`i' & `i'<=12 { /* Jan-Dec 2002 */
	    cd "$locbas"
	    cd 2002
	    unzipfile `month'02pub.zip
	    /* use Jan 1998 coding */
	    !$copy `month'02pub.cps "$locbas/1998/cpsb1998.txt"
		
	    cd "$locbdo"
	    do cps_basic_read_1998.do /* uses Jan 1998 coding */
	    gen int year=2002
	    compress
	    cd "$locbas"
	    cd 2002
	    saveold cps_basic_raw_2002_`i'.dta, replace
	    !$erase `month'02pub.cps
		
	    cd "$locbas"
	    cd 1998
	    !$erase cpsb1998.txt
	    } /* Jan-Dec 2002 */
local i=`i'+1
} /* loop through months */
end

/* 2003 */
capture program drop b2003
program define b2003
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      if 1<=`i' & `i'<=12 {
	  	cd "$locbas"
		cd 2003
		unzipfile `month'03pub.zip
	    /* use Jan 2003 coding */
		!$copy `month'03pub.cps "$locbas/2003/cpsb2003.txt"
	    
		cd "$locbdo"
	    do cps_basic_read_2003.do
	    gen int year=2003
	    compress
	    cd "$locbas"
	    cd 2003
	    saveold cps_basic_raw_2003_`i'.dta, replace
	    !$erase `month'03pub.cps
	    !$erase cpsb2003.txt
		} /* January-December 2003 */
local i=`i'+1
} /* loop through months */
end

	/* 	from May 2004, the CPS changed coding of sub-state
		geographic areas, and the household number variable.
		Changes to the CEPR code on 7-3-07 incorporate the new household
		number variable.
	*/

/* 2004 */
capture program drop b2004
program define b2004
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	if `i'<=4 	{ /* Jan-Apr 2004 */
		cd "$locbas"
		cd 2004
		unzipfile `month'04pub.zip
		/* use Jan 2003 coding until May 2004: */
		!$copy `month'04pub.cps "$locbas/2003/cpsb2003.txt"
		
		cd "$locbdo"
		do cps_basic_read_2003.do /* uses Jan 2003 coding */
		gen int year=2004
		compress
		cd "$locbas"
		cd 2004
		saveold cps_basic_raw_2004_`i'.dta, replace
		!$erase `month'04pub.cps
		
		cd "$locbas"
		cd 2003
		!$erase cpsb2003.txt  /* until May 2004 uses Jan 2003 coding */
		} /* Jan-Apr 2004 */

	if 5<=`i' & `i'<=12 	{ /* May-Dec 2004 */
		cd "$locbas"
		cd 2004
		unzipfile `month'04pub.zip
		/* use May 2004 coding until August 2005 */
		!$copy `month'04pub.cps "$locbas/2004/cpsb2004.txt"
		
		cd "$locbdo"
		do cps_basic_read_2004.do /* uses May 2004 coding */
		gen int year=2004
		compress
		cd "$locbas"
		cd 2004
		saveold cps_basic_raw_2004_`i'.dta, replace
		
		!$erase `month'04pub.cps
		!$erase cpsb2004.txt  /* Starting May 2004, uses May 2004 coding */
		} /* May-Dec 2004 */
local i=`i'+1
} /* loop through months */
end

	/* 	in August 2005, BLS/Census introduced a new
		data dictionary 
	*/

/* 2005 */
capture program drop b2005
program define b2005
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
      if `i'<=7 { /* Jan-Jul 2005 */
		cd "$locbas"
		cd 2005
	    unzipfile `month'05pub.zip
	    /* use May 2004 coding */
		!$copy `month'05pub.cps "$locbas/2004/cpsb2004.txt"
	    
		cd "$locbdo"
	    do cps_basic_read_2004.do /* uses May 2004 coding */
	    gen int year=2005
	    compress
	    cd "$locbas"
	    cd 2005
	    saveold cps_basic_raw_2005_`i'.dta, replace
	    !$erase `month'05pub.cps
		
	    cd "$locbas"
	    cd 2004
	    !$erase cpsb2004.txt
	    } /* Jan-Jul 2005 */
	  if 8<=`i' & `i'<=12 { /* Aug-Dec 2005 */
		cd "$locbas"
	    cd 2005
	    unzipfile `month'05pub.zip
	    /* use Aug 2005 coding */
	    !$copy `month'05pub.cps "$locbas/2005/cpsb2005.txt"
		
	    cd "$locbdo"
	    do cps_basic_read_2005.do /* uses Aug 2005 coding */
	    gen int year=2005
	    compress
	    cd "$locbas"
	    cd 2005
	    saveold cps_basic_raw_2005_`i'.dta, replace
	    !$erase `month'05pub.cps
		!$erase cpsb2005.txt
	    } /* Aug-Dec 2005 */
local i=`i'+1
} /* loop through months */
 
end

/* 2006 */
capture program drop b2006
program define b2006
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2006 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2006 */
		cd "$locbas"
		cd 2006
		unzipfile `month'06pub.zip
		/* use Aug 2005 coding for Jan-Dec 2006*/
		if `i'==1 | `i'==2 {
			!$copy `month'06pub.cps "$locbas/2005/cpsb2005.txt"
		}
		else {
			!$copy `month'06pub.dat "$locbas/2005/cpsb2005.txt"
		}
		
		cd "$locbdo"
		do cps_basic_read_2005.do /* uses Aug 2005 coding */
		gen int year=2006
		compress
		cd "$locbas"
		cd 2006
		saveold cps_basic_raw_2006_`i'.dta, replace
		if `i'==1 | `i'==2 {
			!$erase `month'06pub.cps 
		}
		else {
			!$erase `month'06pub.dat 
		}
		cd "$locbas"
		cd 2005
		!$erase cpsb2005.txt
		} /* Jan-Dec 2006 */
local i=`i'+1
} /* loop through months */

end
 
/* 2007 */
capture program drop b2007
program define b2007
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2007 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2007 */
		cd "$locbas"
		cd 2007
		unzipfile `month'07pub.zip
		/* use Jan 2007 coding */
		!$copy `month'07pub.dat "$locbas/2007/cpsb2007.txt"
		
		cd "$locbdo"
		do cps_basic_read_2007.do /* uses Jan 2007 coding */
		gen int year=2007
		compress
		cd "$locbas"
		cd 2007
		saveold cps_basic_raw_2007_`i'.dta, replace
		!$erase `month'07pub.dat
		!$erase cpsb2007.txt
		} /* Jan-Dec 2007 */
local i=`i'+1
} /* loop through months */
end

/* 2008 */
capture program drop b2008
program define b2008
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2008 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2008 */
		cd "$locbas"
		cd 2008
		unzipfile `month'08pub.zip
		/* use Jan 2007 coding for Jan-Dec 2008*/
		!$copy `month'08pub.dat "$locbas/2007/cpsb2007.txt"
		
		cd "$locbdo"
		do cps_basic_read_2007.do /* uses Jan 2007 coding */
		gen int year=2008
		compress
		cd "$locbas"
		cd 2008
		saveold cps_basic_raw_2008_`i'.dta, replace
		!$erase `month'08pub.dat
		
		cd "$locbas"
		cd 2007
		!$erase cpsb2007.txt
		} /* Jan-Dec 2008 */
local i=`i'+1
} /* loop through months */
end

/* 2009 */
capture program drop b2009
program define b2009
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2009 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2009 */
		cd "$locbas"
		cd 2009
		unzipfile `month'09pub.zip
		/* use Jan 2009 coding for Jan-Dec 2009 */
		!$copy `month'09pub.dat "$locbas/2009/cpsb2009.txt"
		
		cd "$locbdo"
		do cps_basic_read_2009.do /* uses Jan 2009 coding */
		gen int year=2009
		compress
		cd "$locbas"
		cd 2009
		saveold cps_basic_raw_2009_`i'.dta, replace
		!$erase `month'09pub.dat
		!$erase cpsb2009.txt
		} /* Jan-Dec 2009 */
local i=`i'+1
} /* loop through months */
end

/* 2010 */
capture program drop b2010
program define b2010
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2010 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2010 */
		cd "$locbas"
		cd 2010
		unzipfile `month'10pub.zip
		/* use Jan 2010 coding for Jan-Dec 2010*/
		!$copy `month'10pub.dat "$locbas/2010/cpsb2010.txt"
		
		cd "$locbdo"
		do cps_basic_read_2010.do /* uses Jan 2010 coding */
		gen int year=2010
		compress
		cd "$locbas"
		cd 2010
		saveold cps_basic_raw_2010_`i'.dta, replace
		!$erase `month'10pub.dat
		!$erase cpsb2010.txt
		} /* Jan-Dec 2010 */
local i=`i'+1
} /* loop through months */
end

/*2011 */
capture program drop b2011
program define b2011
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2011 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2011 */
		cd "$locbas"
		cd 2011
		unzipfile `month'11pub.zip
		/* shouldn't this use Jan 2010 coding? */
		!$copy `month'11pub.dat "$locbas/2011/cpsb2011.txt"
		
		cd "$locbdo"
		do cps_basic_read_2011.do
		gen int year=2011
		compress
		cd "$locbas"
		cd 2011
		saveold cps_basic_raw_2011_`i'.dta, replace
		!$erase `month'11pub.dat
		!$erase cpsb2011.txt
		} /* Jan-Dec 2011 */
local i=`i'+1
} /* loop through months */
end

/* 2012 */
capture program drop b2012
program define b2012
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	if `i'<=4 	{ /* Jan-April 2012 */
		cd "$locbas"
		cd 2012
		unzipfile `month'12pub.zip
		/* shouldn't this use Jan 2010 coding? */
		!$copy `month'12pub.dat "$locbas/2011/cpsb2011.txt"
		
		cd "$locbdo"
		do cps_basic_read_2011.do /* uses Jan 2011 coding */
		gen int year=2012
		compress
		cd "$locbas"
		cd 2012
		saveold cps_basic_raw_2012_`i'.dta, replace
		!$erase `month'12pub.dat
		
		cd "$locbas"
		cd 2011
		!$erase cpsb2011.txt
		} /* Jan-April 2012 */
	if 5<=`i' & `i'<=12 { /* May-Dec 2012 */
		cd "$locbas"
		cd 2012
		unzipfile `month'12pub.zip
		/* use May 2012 coding */
		!$copy `month'12pub.dat "$locbas/2012/cpsb2012.txt"
		
		cd "$locbdo"
		do cps_basic_read_2012.do /* uses May 2012 coding */
		gen int year=2012
		compress
		cd "$locbas"
		cd 2012
		saveold cps_basic_raw_2012_`i'.dta, replace
		!$erase `month'12pub.dat 
		!$erase cpsb2012.txt
		} /* May-Dec 2012 */
local i=`i'+1
} /* loop through months */
end

/* 2013 */
capture program drop b2013
program define b2013
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2013 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2013 */
		cd "$locbas"
		cd 2013
		unzipfile `month'13pub.zip
		/* use Jan 2013 coding */
		!$copy `month'13pub.dat "$locbas/2013/cpsb2013.txt"
		
		cd "$locbdo"
		do cps_basic_read_2013.do /* uses Jan 2013 coding */
		gen int year=2013
		rename prtage peage
		compress
		cd "$locbas"
		cd 2013
		saveold cps_basic_raw_2013_`i'.dta, replace
		!$erase `month'13pub.dat
		!$erase cpsb2013.txt
		} /* Jan-Dec 2013 */
local i=`i'+1
} /* loop through months */
end

/* 2014 */
capture program drop b2014
program define b2014
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2014 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2014 */
		cd "$locbas"
		cd 2014
		unzipfile `month'14pub.zip
		/* use Jan 2014 coding */
		!$copy `month'14pub.dat "$locbas/2014/cpsb2014.txt"
		
		cd "$locbdo"
		do cps_basic_read_2014.do /* uses Jan 2014 coding */
		gen int year=2014
		rename prtage peage
		compress
		cd "$locbas"
		cd 2014
		saveold cps_basic_raw_2014_`i'.dta, replace
		!$erase `month'14pub.dat
		!$erase cpsb2014.txt
		} /* Jan-Dec 2014 */
local i=`i'+1
} /* loop through months */
end

/* 2015 */
capture program drop b2015
program define b2015
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2015 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2015 */
		cd "$locbas"
		cd 2015
		unzipfile `month'15pub.zip
		/* use Jan 2015 coding */
		!$copy `month'15pub.dat "$locbas/2015/cpsb2015.txt"
		
		cd "$locbdo"
		do cps_basic_read_2015.do /* uses Jan 2015 coding */
		gen int year=2015
		rename prtage peage
		compress
		cd "$locbas"
		cd 2015
		saveold cps_basic_raw_2015_`i'.dta, replace
		!$erase `month'15pub.dat
		!$erase cpsb2015.txt
		} /* Jan-Dec 2015 */
local i=`i'+1
} /* loop through months */
end

/* 2016 */
capture program drop b2016
program define b2016
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2016 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2016 */
		cd "$locbas"
		cd 2016
		unzipfile `month'16pub.zip
		/* use Jan 2015 coding */
		!$copy `month'16pub.dat "$locbas/2015/cpsb2015.txt"
		
		cd "$locbdo"
		do cps_basic_read_2015.do /* uses Jan 2015 coding */
		gen int year=2016
		rename prtage peage
		compress
		cd "$locbas"
		cd 2016
		saveold cps_basic_raw_2016_`i'.dta, replace
		!$erase `month'16pub.dat
		
		cd "$locbas"
		cd 2016
		!$erase cpsb2016.txt
		} /* Jan-Dec 2016 */
local i=`i'+1
} /* loop through months */
end 

/* 2017 */
capture program drop b2017
program define b2017
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2017 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2017 */
		cd "$locbas"
		cd 2017
		unzipfile `month'17pub.zip
		/* use Jan 2017 coding */
		!$copy `month'17pub.dat "$locbas/2017/cpsb2017.txt"
		
		cd "$locbdo"
		do cps_basic_read_2017.do /* uses Jan 2017 coding */
		gen int year=2017
		rename prtage peage
		compress
		cd "$locbas"
		cd 2017
		saveold cps_basic_raw_2017_`i'.dta, replace
		!$erase `month'17pub.dat		
		!$erase cpsb2017.txt
		} /* Jan-Dec 2017 */
local i=`i'+1
} /* loop through months */
end

/* 2018 */
capture program drop b2018
program define b2018
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2018 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2018 */
		cd "$locbas"
		cd 2018
		unzipfile `month'18pub.zip
		/* use Jan 2017 coding */
		!$copy `month'18pub.dat "$locbas/2018/cpsb2018.txt"
		
		cd "$locbdo"
		do cps_basic_read_2018.do /* uses Jan 2017 coding */
		gen int year=2018
		rename prtage peage
		compress
		cd "$locbas"
		cd 2018
		saveold cps_basic_raw_2018_`i'.dta, replace
		!$erase `month'18pub.dat
		!$erase cpsb2018.txt
		} /* Jan-Dec 2018 */
local i=`i'+1
} /* loop through months */
end

/* 2019 */
capture program drop b2019
program define b2019
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2019 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2019 */
		cd "$locbas"
		cd 2019
		unzipfile `month'19pub.zip
		/* use Jan 2017 coding */
		!$copy `month'19pub.dat "$locbas/2019/cpsb2019.txt"
		
		cd "$locbdo"
		do cps_basic_read_2019.do /* uses Jan 2017 coding */
		gen int year=2019
		rename prtage peage
		compress
		cd "$locbas"
		cd 2019
		saveold cps_basic_raw_2019_`i'.dta, replace
		!$erase `month'19pub.dat 
		!$erase cpsb2019.txt
		} /* Jan-Dec 2019 */
local i=`i'+1
} /* loop through months */
end

/*ch*/
/* 2020 */
capture program drop b2020
program define b2020
local i=1
foreach month in jan feb mar apr may jun jul aug sep oct nov dec {
	/* Jan-Dec 2020 */
	if 1<=`i' & `i'<=12 { /* Jan-Dec 2020 */
		cd "$locbas"
		cd 2020
		unzipfile `month'20pub.zip
		/* use Jan 2017 coding */
		!$copy `month'20pub.dat "$locbas/2019/cpsb2019.txt"
		
		cd "$locbdo"
		do cps_basic_read_2019.do /* uses Jan 2017 coding */
		gen int year=2020
		rename prtage peage
		compress
		cd "$locbas"
		cd 2020
		saveold cps_basic_raw_2020_`i'.dta, replace
		!$erase `month'20pub.dat 
		
		cd "$locbas"
		cd 2019
		!$erase cpsb2019.txt
		} /* Jan-Dec 2019 */
local i=`i'+1
} /* loop through months */
end

/* 
Copyright 2020 CEPR, Hayley Brown, and John Schmitt

This file is part of the cepr_org_master.do program. This file and all
programs referenced in it are free software. You can redistribute the
program or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
USA.
*/
